package br.edu.ifrn.sgpapp.activity;

import java.util.List;

import android.os.Bundle;
import android.widget.ListView;
import br.edu.ifrn.sgp.dtos.HistoricoStatusProcessoDTO;
import br.edu.ifrn.sgp.dtos.ProcessoDTO;
import br.edu.ifrn.sgpapp.R;
import br.edu.ifrn.sgpapp.adapter.HistoricoStatusProcessoListAdapter;
import br.edu.ifrn.sgpapp.util.ValidatorUtil;

public class ListarHistoricoStatusProcessoActivity extends GenericActivity<List<HistoricoStatusProcessoDTO>> {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.lista_geral);
		processarSolicitacao();
	}
	
	@Override
	public List<HistoricoStatusProcessoDTO> doInBackgroundTask(String... params) {
		ProcessoDTO processo = (ProcessoDTO) getIntent().getSerializableExtra(getString(R.string.extra_processo));
		
		if (ValidatorUtil.isNotEmpty(processo.getArquivosProcesso())){
			return (List<HistoricoStatusProcessoDTO>) processo.getHistoricoStatus();
		}
		
		return null;
	}

	@Override
	public void onPostExecuteTask(final List<HistoricoStatusProcessoDTO> historicoStatus) {
		ListView listaHistorico = (ListView) findViewById(R.id.list);
		HistoricoStatusProcessoListAdapter adapter = new HistoricoStatusProcessoListAdapter(this, historicoStatus);
		listaHistorico.setAdapter(adapter);
		listaHistorico.setEmptyView(findViewById(R.id.textEmptyView));
	}
}
